package chpt05;


import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class CountSet {

	public static void main(String[] args) {
		Set<String> strSet = new TreeSet<String>();
		Scanner in = new Scanner(System.in);
		int m = 10;
		while (in.hasNext()) {
			String str = in.next();
			if(str.equals("!!!!!"))
				break;
			else if (!strSet.contains(str))
				strSet.add(str);
		}
		System.out.println(strSet.size());
		strSet.toArray();
		if (strSet.size() <= 10)
			for (String s : strSet) {
				System.out.println(s);
			}
		else
			for (String s : strSet) {
				if (m-- <= 0)
					break;
				System.out.println(s);
			}
		in.close();

	}

}
